﻿using AutoMapper;
using IdentityServer4Blazor.Model;
using IdentityServer4Blazor.Shared.Dto.Role;
using IdentityServer4Blazor.Shared.Dto.User;
using Microsoft.AspNetCore.Identity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace IdentityServer4Blazor.Server.AutoMapper
{
    public class UserProfile : Profile
    {
        public UserProfile()
        {
            CreateMap<CreateUserInput, User>();
            CreateMap<User, UserListOutput>();
            CreateMap<IdentityUserClaim<int>, UserClaimsOutput>()
                .ForMember(x=>x.Type,y=>y.MapFrom(c=>c.ClaimType))
                .ForMember(x => x.Value, y => y.MapFrom(c => c.ClaimValue));
        }
    }
    public class RoleProfile : Profile
    {
        public RoleProfile()
        {
            CreateMap<CreateRoleInput, Role>();
        }
    }
}
